package com.gpjcjl.database;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.gpjcjl.entity.Record;
import com.gpjcjl.entity.RecordDetail;

import java.util.List;

@Dao
public interface RecordDetailDao {

    @Query("SELECT * FROM recorddetail")
    List<RecordDetail> findAll();

    @Query("SELECT * FROM recorddetail WHERE rid = :recordId")
    List<RecordDetail> findByRecordId(String recordId);

    @Query("SELECT * FROM recorddetail WHERE rid = :recordId and check_num like '%' || :keyword || '%'")
    List<RecordDetail> findByKeyword(String recordId, String keyword);

    @Insert
    void insertAll(RecordDetail... details);

    @Delete
    void delete(RecordDetail detail);

    @Update
    void update(RecordDetail detail);
}
